<?php

/**
 * Abstract database driver class.
 * Provides some basic methods to interact with databses.
 *  
 * @package SpotLight.core.db
 * @version since begin
 * @author asmhack
 * @license GPL
 * @copyright Serhiy Zaporozhets'
 */
abstract class DBDriver {
   /**
    * @deprecated
    */
   protected $log;
   
   protected $link;
   
   protected $res;
   
   /**
    * 
    * constructor method that connect to DB at the same time.
    * 
    * @param $dbConfHost database host
    * @param $dbConfLogin database login
    * @param $dbConfPasswd database password
    * @param $dbConfDB database name
    * @param $encoding database encoding (charset)
    * @return new DBDriver instance.
    */
   public function __construct($dbConfHost, $dbConfLogin, $dbConfPasswd, $dbConfDB, $encoding) {
      $this->connect ( $dbConfHost, $dbConfLogin, $dbConfPasswd, $dbConfDB, $encoding );
   }
   
   private function __clone() {
   }
   
   /**
    * Connect to database.
    * 
    * @param $dbConfHost database host
    * @param $dbConfLogin database login
    * @param $dbConfPasswd database password
    * @param $dbConfDB database name
    * @param $encoding database encoding (charset)
    */
   abstract protected function connect($dbConfHost, $dbConfLogin, $dbConfPasswd, $dbConfDB, $encoding);
   
   /**
    * Send query to DB. Query is NOT prepeared.
    * @param $query string query string
    */
   abstract public function query($query);
   
   /**
    * 
    * Get database error if it exist. 
    * @return error type
    */
   abstract public function error();
   
   /**
    * 
    * Get result of last query. 
    * @return unknown_type
    */
   abstract public function getQueryResult();
   
   /**
    * 
    * Escape string.
    * @param $str string that need to escape.
    * @return unknown_type
    */
   abstract public function escapeString($str);
   
   /**
    * 
    * Fetch row as assoc array 
    * @return array
    */
   abstract public function fetch_assoc();
   
   /**
    * 
    * Fetch row as object.
    * @return object
    */
   abstract public function fetch_object();
   
   /**
    * 
    * Fetch all rows to matrix.
    * @return array of array
    */
   abstract public function fetch_all();
   
   /**
    * 
    * Return amount of affected rows by last query.
    * @return int
    */
   abstract public function affected_rows();
   
   /**
    * 
    * Get number of rows in result.
    * @return int
    */
   abstract public function num_rows();
   
   /**
    * 
    * Close connection.
    * @return unknown_type
    */
   abstract public function close();
   
   /**
    * 
    * Get link to database.
    * @return unknown_type
    */
   abstract public function getLink();
   
   /**
    * Select databse.
    * @param $dbName string database name.
    * @return unknown_type
    */
   abstract public function select_db($dbName);
   
   /**
    * @return last insert id
	*/
   abstract public function last_id();
   
   /**
    * 
    * а я не помню че это фигня. че она тут делает, хз. вытру в следующей версии. а пока будет как - 
    * @deprecated will be removed since 0.5.0.2, (возможно)
    * @return unknown_type
    */
   public function getRes() {
      return $this->res;
   }

}

?>